//
//  News.m
//  Bus
//
//  Created by wangjiajia on 13-8-2.
//  Copyright (c) 2013年 wangjiajia. All rights reserved.
//

#import "News.h"

@implementation News
@synthesize articleID;//.h文件中没有该变量声明，会在.m文件中声明一个(私有)全局变量articleID
@synthesize title;
@synthesize sendTime;
@synthesize sendUserName;

-(News *)initWithParameters:(int)_articleID andTitle:(NSString *)_title andSendTime:(NSString *)_sendTime andSendUserName:(NSString *)_sendUserName{
    News* news=[[News alloc] init];
    news.articleID=_articleID;//如果叫articleID，该局部变量会隐藏(屏蔽)全局的articleID
    //articleID=_articleID;//这里的赋值是对全局变量articleID的赋值，对news对象没影响
    news.title=_title;
    news.sendTime=_sendTime;
    news.sendUserName=_sendUserName;
    return news;
}
-(NSString *)description{
//需要加上self，会调用对象的get方法，表示访问对象自身的内存。否则访问的是类的私有全局变量，没有分配内存呢，造成Bad_Access!!
    return [NSString stringWithFormat:@"%i,%@,%@,%@",self.articleID,self.title,self.sendTime,self.sendUserName];
}
@end
